/**
 * 数据适配工具, 用于根据参数返回不同格式的json
 * */
var mapping = require('../config.json').scales;

module.exports = function (data, type) {
  if(!data.scale) data.scale = 0;
  switch (type) {
    case 'detail':
      return data;
    case 'phonetic':
      return data.phonetic;
    case 'explains':
      return {
        outline: data.outline,
        meanings: data.meanings,
        explains: data.explains
      };
    case 'scale':
      return {scale: data.scale, name: mapping[data.scale] || mapping[0]};
  }
};